package com.yantong.mapper;

import com.yantong.pojo.Ticket;
import com.yantong.pojo.TicketExample;
import com.yantong.pojo.vo.TicketVo;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
import java.util.Map;

/**
 * @author kanghaixin
 */
public interface TicketMapper {
    /**
     * 条件统计
     * @param example
     * @return
     */
    int countByExample(TicketExample example);

    /**
     * 主键删除
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Long id);

    /**
     * 适配插入
     * @param record
     * @return
     */
    int insertSelective(Ticket record);

    /**
     * 条件查询
     * @param example
     * @param rowBounds
     * @return
     */
    List<Ticket> selectByExample(TicketExample example, RowBounds rowBounds);

    /**
     * 获取详情
     * @param id
     * @return
     */
    Ticket selectByPrimaryKey(Long id);

    /**
     * 主键适配更新
     * @param record
     * @return
     */
    int updateByPrimaryKeySelective(Ticket record);

	/**
	 * 修改字段为空
	 * @param record
	 * @return
	 */
	int updateByNull(Ticket record);

	int updateByNullByUsableTeam(Ticket record);

    /**
     * 检查是否有超过有效期的优惠券
     * @return
     */
    int checkTicket();

    /**
     * 查询优惠券列表（是否可领用）
     */
    int countCouponList(Map<String, Object> map);
    List<Map<String,Object>> couponList(Map<String, Object> map, RowBounds rowBounds);

	Ticket selTicketRanType(int rangeType);
	/**
	 * 获取有效期内首次登陆新人券
	 * @param queryMap
	 * @return
	 */
	List<Ticket> setFirstLoginCoup(Map<String, Object> queryMap);
	/**
	 * 查询有效期内最近的未领取的优惠券
	 * @param queryMap
	 * @return
	 */
	TicketVo selUncellectCoup(Map<String, Object> queryMap);
	/**
	 * 减库存
	 * @param id
	 * @return
	 */
	int decrementTicket(Long id);

	int updateRecord(Map<String, Object> updMap);

	TicketVo selMidTicket(Map<String, Object> queryMap1);

	List<Ticket> queryList(Map params);

	int count(Map params);

	List<Ticket> queryTickerList(Map params, RowBounds rowBounds);

	List<Ticket> queryTickerListByFreeCharge(Map params, RowBounds rowBounds);
}